<template>
  <div class='member-order-detail' v-if="order">
    <!-- 头部 -->
    <DetailAction :order="order"></DetailAction>
    <!-- 进度 -->
    <DetailSteps :order="order"></DetailSteps>
    <!-- 物流 -->
    <suspense>
      <template #default>
        <DetailLogistics v-if="[3, 4, 5].includes(order.orderState)" :order="order"></DetailLogistics>
      </template>
      <template #fallback>
        loing...
      </template>
    </suspense>
    <!-- 信息 -->
    <DetailInfo :order="order"></DetailInfo>
  </div>
</template>

<script>
import { useRoute } from 'vue-router'
import { findOrderDetail } from '@/api/order'
import { ref } from 'vue'
import DetailAction from './components/detail-action.vue'
import DetailSteps from './components/detail-steps.vue'
import DetailLogistics from './components/detail-logistics.vue'
import DetailInfo from './components/detail-info.vue'

export default {
  name: 'MemberDetail',
  components: {
    DetailAction,
    DetailSteps,
    DetailLogistics,
    DetailInfo
  },
  setup() {
    const route = useRoute()
    const order = ref(null)
    findOrderDetail(route.params.id).then(data => {
      order.value = data.result
    })
    return {
      order
    }
  }
}
</script>

<style lang='less' scoped>
.member-order-detail {
  background: #fff;
  height: 100%;
}
</style>